#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
#include <vector>
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    s = " " + s;
    //s  h  y
    vector<vector<int>> v(n + 1, vector<int>(3, 0));
    for (int i = 1; i <= n; i++)
    {
        v[i][0] = v[i - 1][0];
        v[i][1] = v[i - 1][1];
        v[i][2] = v[i - 1][2];

        if (s[i] == 's')
        {
            v[i][0] = v[i - 1][0] + 1;
        }
        else if (s[i] == 'h')
        {
            v[i][1] += v[i - 1][0];
        }
        else if (s[i] == 'y')
        {
            v[i][2] += v[i - 1][1];
        }
        //cout<<i<<":"<<v[i][0]<<" "<<v[i][1]<<" "<<v[i][2]<<endl;
    }
    cout << v[n][2];

    return 0;
}
/*
struct ListNode {
	int val;
	struct ListNode *next;
	ListNode(int x) :
			val(x), next(NULL) {
	}
};*/
class Solution {
public:
	ListNode* FindFirstCommonNode(ListNode* pHead1, ListNode* pHead2) {
		if (pHead1 == nullptr || pHead2 == nullptr)
			return nullptr;
		int len1 = 0;
		int len2 = 0;
		ListNode* cur1 = pHead1;
		ListNode* cur2 = pHead2;
		while (cur1)
		{
			cur1 = cur1->next;
			len1++;
		}
		while (cur2)
		{
			cur2 = cur2->next;
			len2++;
		}
		ListNode* plong = pHead1;
		ListNode* pshort = pHead2;
		int gap = len1 - len2;
		if (len2 > len1)
		{
			plong = cur2;
			pshort = cur1;
			gap = len2 - len1;
		}
		//cout<<plong->val<<endl;
		while (gap--)
		{
			plong = plong->next;
		}
		//cout<<plong->val<<endl;

		while (pshort && plong)
		{
			if (pshort == plong)
				return pshort;
			pshort = pshort->next;
			plong = plong->next;
		}
		return nullptr;
	}
};
#include <iostream>
using namespace std;
#include <string>
#include <unordered_map>
int main() {
    string s;
    getline(cin, s);
    //cout<<s<<endl;
    string target;
    cin >> target;
    //cout<<target<<endl;
    unordered_map<char, int> m;
    for (auto e : target)
    {
        m[e]++;
    }
    // for(auto e:s)
    // {
    //     if(m[e]!=0)
    //     {
    //         cout<<e;
    //     }
    // }
    for (int i = 0; i < s.size(); i++)
    {
        if (m.count(s[i]) == 0)
        {
            cout << s[i];
        }
    }
    return 0;
}